﻿<Menu>
    <MenuItem @key="0" OnClick="UserCenter">
        <a>
            个人中心
        </a>
    </MenuItem>
    <MenuItem @key="1" OnClick="ChangePassword">
        <a>
            修改密码
        </a>
    </MenuItem>
    <MenuDivider />
    <MenuItem @key="3" OnClick="UserOut">
        退出登录
    </MenuItem>
</Menu>
@code {


    [Inject]
    IJSRuntime jSRuntime { get; set; }
    [Inject]
    NavigationManager navigationManager { get; set; }
    [Inject]
    HttpHelper Http { get; set; }
    [Inject]
    MessageService messageService { get; set; }
    [Inject]
    CavModal CavModal { get; set; }

    public async void UserOut()
    {
        await jSRuntime.InvokeVoidAsync("delCookie", Config.CookieName);
        Http.IsSetCookie = false;
        navigationManager.NavigateTo("/",true);
        messageService.Success("退出登录成功");
    }

    public void UserCenter()
    {
        string url = "User/MyDetails";
        navigationManager.NavigateTo(url);
    }

    public async void ChangePassword()
    {
        await CavModal.Create("user/UpdatePwd", "修改密码");
    }
}
